<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" import="com.student.model. *" import="java.util.*"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!-- <!DOCTYPE html> -->
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<script src="https://cdn.staticfile.org/jquery/3.3.0/jquery.min.js"></script>
<link href="https://fastly.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.38/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://fastly.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.38/assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">
<link href="https://fastly.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.38/examples/navbar/navbar.css" rel="stylesheet">
<script src="https://fastly.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.38/assets/js/ie-emulation-modes-warning.js"></script>
<link rel="stylesheet" href="${pageContext.request.contextPath }/css/chooseCourse.css"></link>
<title>在线选课系统-课程一览</title>
</head>
<body>
<%
	User user = (User) request.getSession().getAttribute("info");
	%>
	<!-- 头部 -->
	<header>
		<div class="header">
			<div class="header-left">
				<img src="${ pageContext.request.contextPath }/images/selection.png"> 
				<span>在线选课系统</span>
			</div>
			<div class="header-right">
				<span>欢迎你，<%=user.getRealname() %></span>
				<a href="${ pageContext.request.contextPath }/ShowChooseCoursePageServlet">继续选课</a>
				<span>|</span>
				<div class="logout">
					<a href="${ pageContext.request.contextPath }/LogoutServlet">安全退出</a>
					<img src="${ pageContext.request.contextPath }/images/logout.png">
				</div>
			</div>
		</div>
	</header>
	
	<!-- 表格 -->
	<div class="content">
		<div class="alert alert-info title" role="alert">
			<div>你已选择的课程列表如下，当前选课的总学分为：<%=session.getAttribute("totalPoint") %> 分</div>
			<div>
				<%  
					Object msg = request.getAttribute("msg");
					if (msg!=null)  out.print("<span style='color:#449d44;;'>提示：退课成功！</span>");
				%>
			</div>
		</div>
		<div class="table">
			<table class="table table-hover table-bordered" style="text-align:center">
			  <thead>
			    <tr>
			      <th scope="col">课程编号</th>
			      <th scope="col">课程名称</th>
			      <th scope="col">授课老师</th>
			      <th scope="col">学分</th>
			      <th scope="col">第一次上课时间</th>
			      <th scope="col">第二次上课时间</th>
			      <th scope="col">上课地点</th>
			      <th scope="col">操作</th>
			    </tr>
			  </thead>
			  <tbody>
			  	<c:forEach items="${selectCourseList }" var="course">
			  		<tr>
				      <td scope="row">${course.course_id }</td>
				      <td>${course.course_name }</td>
				      <td>${course.teacher }</td>
				      <td>${course.point}</td>
				      <td>${course.time_1}</td>
				      <td>${course.time_2 }</td>
				      <td>${course.location }</td>
				      <td>
				      	<a class="btn btn-success btn-sm" id="delete" href="${pageContext.request.contextPath}/DelSelectCourseServlet?course_id=${course.course_id}" role="button">退课</a>
				      </td>
			  	</c:forEach>
			  </tbody>
			</table>
		</div>
	</div>
	<script type="text/javascript">
		 $(function() {
		  // 给删除的a标签绑定单机事件 用于删除确认提示操作
		  $("a#delete").click(function() {
		   return confirm("确认退课吗？");
		  });
		 }); 
	</script>
</body>
</html>